package com.luxsoft.sw3.bi.alta;

import java.util.List;

import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;


import org.springframework.util.Assert;

import com.luxsoft.siipap.swing.browser.FilteredBrowserPanel;
import com.luxsoft.sw3.cfd.model.ComprobanteFiscal;
import com.luxsoft.sw3.ui.utils.FacturaForm;

public class CFDPanel extends FilteredBrowserPanel<ComprobanteFiscal>{
	
	private final AltAController controller;

	public CFDPanel(AltAController controller) {
		super(ComprobanteFiscal.class);
		Assert.notNull(controller);
		this.controller=controller;
		
		setTitle("Comprobantes fiscales digitales (CFD)");		
	}
	
	public void init(){
		addProperty(
				"serie","tipo","folio","log.creado","total"
				);
		addLabels(
				"Serie","Tipo","Folio","Fecha","Total"
				);
		
		manejarPeriodo();
	}
	
	@Override
	protected void afterGridCreated() {		
		super.afterGridCreated();
		JPopupMenu popup=new JPopupMenu("Operaciones");
		for(Action a:getActions()){
			popup.add(a);
		}
		getGrid().setComponentPopupMenu(popup);
	}

	@Override
	protected List<ComprobanteFiscal> findData() {
		return controller.buscarComprobantesFiscales(periodo);
	}

	/*
	@Override
	protected JComponent buildHeader() {
		// TODO Auto-generated method stub
		return super.buildHeader();
	}
	*/
	
	@Override
	protected void doSelect(Object bean) {
		ComprobanteFiscal cfd=(ComprobanteFiscal)bean;
		controller.mostrarDetalleDeComprobante(cfd);
	}
	
	

}
